﻿<%@ Page Language="C#" MasterPageFile="~/Template/Edit.master" AutoEventWireup="true"
    CodeFile="EditAttendencesList.aspx.cs" Inherits="Page_EditAttendencesList" Title="Untitled Page" %>

<%@ Register Src="~/Control/ListHeader.ascx" TagName="ListHeader" TagPrefix="wsc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">

    <script type="text/javascript" src="../Js/jquery.js"></script>

    <script type="text/javascript" src="../Js/calendar.js"></script>

    <script type="text/javascript">
        function refreshParent() {
            try {
                window.opener.document.getElementById('ctl00$ListToolBarPlaceHolder$btnRefresh').click();
            }
            catch (e) {
            }
        }
        function JudgeDate(type, date) {
            $.get("../Ajax/DateJudgement.ashx", { Type: type, Date: date, NoCache: Math.random() * 10000 }, function(data) {
                if (type == "weekend") {
                    if (eval(data))
                        $("#<%=cbIsWeekEnd.ClientID %>").attr("checked", "checked");
                    else
                        $("#<%=cbIsWeekEnd.ClientID %>").removeAttr("checked");
                }
                if (type == "holiday") {
                    if (eval(data))
                        $("#<%=cbIsholiday.ClientID %>").attr("checked", "checked");
                    else
                        $("#<%=cbIsholiday.ClientID %>").removeAttr("checked");
                }
            });
        }
        function getPlace(text) {
            $("#divPlace .MainInfolist").html("<tr style=\"display:none\"><td></td></tr>");
            $.get("../Ajax/getAttendencePlace.ashx", { deptName: text, nc: Math.random() * 10000 }, function(data) {
                var Places = eval(data);
                var HTML = "";
                for (var i = 0; i < Places.length; i++) {
                    HTML += "<tr style=\"cursor: hand\" class=\"Normal\" oldclass=\"Normal\" onmouseover=\"OverChangeClass(this);\" onmouseout=\"ReturnClass(this)\" onclick=\"setPlace('" + Places[i] + "')\">";
                    HTML += "<td>" + Places[i] + "</td></tr>";
                }
                $("#divPlace .MainInfolist").html(HTML);
                $("#divPlace").show();
            });
        }
        function setPlace(place) {
            $("#<%=tbPlace.ClientID%>").val(place);
            $("#divPlace").hide();
        }
        var OldDate;
        function Judge() {
            var Date = $("#<%=tbAttendDate.ClientID %>").val();
            if (Date != OldDate) {
                JudgeDate("weekend", Date);
                JudgeDate("holiday", Date);
                OldDate = Date;
            }
            setTimeout(Judge, 10);
        }
        document.onclick = function() {
            var obj = event.srcElement ? event.srcElement : event.target;
            if (obj.id != "<%=tbPlace.ClientID%>" && obj.id != "divPlace") {
                $("#divPlace").hide();
            }
        }
        $(function() {
            OldDate = $("#<%=tbAttendDate.ClientID %>").val();
            Judge();
        });
        function SelectUser() {
            var returnValue = window.showModalDialog("../Function.Web/UserChooser.aspx?SelectType=User&nocache=" + Math.random() * 10000 + "&ReturnValueFormat="
            + encodeURI("<%=txtUserID.ClientID %>:ID|<%=txtUserName.ClientID%>:Name|<%=txtUserDisplayName.ClientID %>:DisplayName"),
            document, "dialogWidth:800px;dialogHeight:600px;status:yes;resizable:no");
        }
        function SelectPLUser() {
            var returnValue = window.showModalDialog("../Function.Web/UserChooser.aspx?SelectType=User&nocache=" + Math.random() * 10000 + "&ReturnValueFormat="
            + encodeURI("<%=txtPLUserID.ClientID%>:ID|<%=txtPLUserName.ClientID%>:Name|<%=txtPLUserDisplayName.ClientID %>:DisplayName"),
            document, "dialogWidth:800px;dialogHeight:600px;status:yes;resizable:no");
        }
        function SelectOtherUser() {
            var SelID = document.getElementById('<%=txtOtherUserID.ClientID%>').value;
            var returnValue = window.showModalDialog("OtherUserList.aspx?SelID=" + SelID + "&SelectType=User&nocache=" + Math.random() * 10000 + "&ReturnValueFormat="
            + encodeURI("<%=txtOtherUserID.ClientID%>:ID|<%=txtOtherUserDisplay.ClientID %>:DisplayName"),
            document, "dialogWidth:800px;dialogHeight:600px;status:yes;resizable:no");
        }
        function SelectPLOtherUser() {
            var SelID = document.getElementById('<%=txtPLOtherUserID.ClientID%>').value;
            var returnValue = window.showModalDialog("OtherUserList.aspx?SelID=" + SelID + "&SelectType=User&nocache=" + Math.random() * 10000 + "&ReturnValueFormat="
            + encodeURI("<%=txtPLOtherUserID.ClientID%>:ID|<%=txtPLOtherUserDisplay.ClientID %>:DisplayName"),
            document, "dialogWidth:800px;dialogHeight:600px;status:yes;resizable:no");
        }
    </script>

    <style type="text/css">
        .btn
        {
            border-right: #2C59AA 1px solid;
            padding-right: 2px;
            border-top: #2C59AA 1px solid;
            padding-left: 2px;
            font-size: 12px;
            filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#C3DAF5);
            border-left: #2C59AA 1px solid;
            cursor: hand;
            color: black;
            padding-top: 2px;
            border-bottom: #2C59AA 1px solid;
        }
        LABEL
        {
            color: #15428b;
        }
        .TitleBar .Normal
        {
            color: Blue;
            vertical-align: top;
            float: right;
            margin: 1px;
        }
        .TitleBar .Over
        {
            color: Blue;
            vertical-align: top;
            float: right;
            border: 1px solid #99BBE8;
            background: #baddf8;
        }
        .TitleBar span
        {
            white-space: nowrap;
            color: #15428B;
            line-height: 16px;
            padding: 2px 4px;
            vertical-align: middle;
        }
        .TitleBar span img
        {
            margin: 2px 0;
            vertical-align: text-bottom;
        }
        .EditPageForm
        {
            padding: 0px;
            background-color: #DFE8F6;
        }
    </style>
    <link href="../Style/Css/calendar.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ToolBarContentPlaceHolder" runat="Server">
    <table border="0" cellspacing="0" cellpadding="2">
        <tr>
            <td class="ToolMenuEdit">
                <div class="Normal" oldclass="Normal" onmouseover="OverChangeClass(this);" onmouseout="ReturnClass(this)">
                    <asp:LinkButton runat="server" ID="lbtnSave" OnClick="lbtnSave_Click">
                    <span><img src="../Images/Icon/Object/Dataset-add.gif" /></span><span>添加</span></asp:LinkButton>
                </div>
            </td>
            <td class="Fg">
                <img src="../Images/FgLine.gif" alt="" />
            </td>
            <td class="ToolMenuEdit">
                <div class="Normal" oldclass="Normal" onmouseover="OverChangeClass(this);" onmouseout="ReturnClass(this)">
                    <asp:LinkButton runat="server" ID="lbtnSendMsg" OnClick="lbtnSendMsg_Click">
                    <span><img src="../Images/Icon/Object/Dataset-add.gif" /></span><span>发送短信</span></asp:LinkButton>
                </div>
            </td>
            <td class="Fg">
                <img src="../Images/FgLine.gif" alt="" />
            </td>
            <td class="ToolMenuEdit">
                <div class="Normal" oldclass="Normal" onmouseover="OverChangeClass(this);" onmouseout="ReturnClass(this)"
                    onclick="window.close();">
                    <span>
                        <img src="../Images/Icon/Action/delete.gif" alt="关闭" /></span><span>关闭</span>
                </div>
            </td>
            <td>
            </td>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FieldContentPlaceHolder" runat="Server">
    <table id="commandTable" border="0" cellspacing="0" cellpadding="0" class="FormTable tablefix"
        width="100%">
        <tr class="FTitle">
            <td colspan="5" style="position: relative; border: #99bbe8 1px solid;" class="TitleBar">
                <div class="MainTitle">
                    值班信息</div>
                <div class="Normal">
                </div>
            </td>
        </tr>
        <tr>
            <td class="FieldName" width="100">
                <span>&nbsp;值班名称：</span>
            </td>
            <td class="FieldInput" colspan="4">
                <asp:TextBox ID="tbName" Width="180px" runat="server" CssClass="InputSmall"></asp:TextBox>
                &nbsp; <span class="Alter">*</span><asp:RequiredFieldValidator ID="RequiredFieldValidator1"
                    runat="server" ControlToValidate="tbName">必填</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="FieldName">
                <span>&nbsp;值班地点：</span>
            </td>
            <td class="FieldInput" colspan="4" style="position: relative">
                <asp:TextBox ID="tbPlace" Width="180px" runat="server" CssClass="InputSmall" onclick="getPlace('');"></asp:TextBox>
                <div style="position: absolute; top: 30px; left: 0px; width: 180px; overflow-y: scroll;
                    display: none; height: 60px; background-color: White; border: #99bbe8 1px solid;"
                    id="divPlace">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="MainInfolist">
                    </table>
                </div>
                &nbsp; <span class="Alter">*</span><asp:RequiredFieldValidator ID="RequiredFieldValidator2"
                    runat="server" ControlToValidate="tbPlace">必填</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="FieldName" style="height: 50px">
                <span>&nbsp;值班内容：</span>
            </td>
            <td class="FieldInput" colspan="4">
                <asp:TextBox ID="tbDescription" runat="server" CssClass="TextArea01" Style="width: 90%;
                    background-color: White; overflow: hidden" TextMode="MultiLine" Rows="3"></asp:TextBox>
                <span>&nbsp;</span>
            </td>
        </tr>
        <tr>
            <td colspan="5">
                <hr />
            </td>
        </tr>
        <tr class="FTitle">
            <td colspan="5" style="position: relative; border: #99bbe8 1px solid;" class="TitleBar">
                <div class="MainTitle">
                    批量添加</div>
                <div class="Normal" oldclass="Normal" onmouseover="OverChangeClass(this);" onmouseout="ReturnClass(this)">
                    <asp:LinkButton runat="server" ID="btnPLAdd" OnClick="btnPLAdd_Click" ValidationGroup="vg2">
                        <span >
                            <img src="<%=ResolveUrl("~/Images/add.png")%>" alt="批量添加" /></span><span>批量添加</span></asp:LinkButton>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="5" style="width: 100%; border-left: #99bbe8 1px solid; border-right: #99bbe8 1px solid;
                height: 5px">
                &nbsp;
            </td>
        </tr>
        <tr valign="middle">
            <td class="FieldName" style="height: 25px; border-left: #99bbe8 1px solid;">
                <span>&nbsp;值班日期：</span>
            </td>
            <td class="FieldName FieldInput" colspan="4" style="width: 100%; text-align: left;
                margin: 0; padding: 0; border-right: #99bbe8 1px solid;">
                <asp:TextBox ID="txtPLStartDate" Width="116px" runat="server" onfocus="calendar();"
                    CssClass="InputSmall"></asp:TextBox>
                &nbsp;<span>至</span>&nbsp;<asp:TextBox ID="txtPLEndDate" Width="116px" runat="server"
                    onfocus="calendar();" CssClass="InputSmall"></asp:TextBox>
                &nbsp;&nbsp;其中的&nbsp;&nbsp;<span>星期</span>&nbsp;<asp:DropDownList runat="server"
                    ID="ddlWeek">
                </asp:DropDownList>
                 
                <asp:CheckBox runat="server" Text="节假日" ID="cbIsHoliday2" />
            </td>
        </tr>
        <tr>
            <td class="FieldName" style="border-left: #99bbe8 1px solid;">
                <span>&nbsp;值班人员：</span>
            </td>
            <td class="FieldInput" colspan="4" style="border-right: #99bbe8 1px solid;">
                <div style="display: none">
                    <asp:TextBox ID="txtPLUserID" runat="server" CssClass="InputSmall"></asp:TextBox>
                    <asp:TextBox ID="txtPLUserName" runat="server" CssClass="InputSmall"></asp:TextBox>
                    <asp:TextBox ID="txtPLOtherUserID" runat="server" CssClass="InputSmall"></asp:TextBox>
                </div>
                <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td width="100">
                            平台用户：
                        </td>
                        <td>
                            <asp:TextBox ID="txtPLUserDisplayName" runat="server" CssClass="InputSmall" onfocus="SelectPLUser();"
                                Width="150"></asp:TextBox>
                        </td>
                        <td width="100">
                            其他用户
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="txtPLOtherUserDisplay" runat="server" CssClass="InputSmall"
                                onfocus="SelectPLOtherUser();" Width="150"></asp:TextBox>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td class="FieldName" style="border-left: #99bbe8 1px solid;">
                <span>&nbsp;值班类型：</span>
            </td>
            <td colspan="4" class="FieldInput" style="border-right: #99bbe8 1px solid;">
                <asp:DropDownList runat="server" ID="rpType2">
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="vg2" runat="server"
                    ErrorMessage="请选择" ControlToValidate="rpType2"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td colspan="5" style="border-left: #99bbe8 1px solid; border-right: #99bbe8 1px solid;
                border-bottom: #99bbe8 1px solid;">
                <hr />
            </td>
        </tr>
        <tr>
            <td colspan="5" style="height: 20px">
                &nbsp;
            </td>
        </tr>
        <tr class="FTitle">
            <td colspan="5" style="position: relative; border: #99bbe8 1px solid;" class="TitleBar">
                <asp:HiddenField ID="txtItemID" runat="server" />
                <div class="MainTitle">
                    单条添加</div>
                <div class="Normal" oldclass="Normal" onmouseover="OverChangeClass(this);" onmouseout="ReturnClass(this)">
                    <asp:LinkButton runat="server" ID="btnAddItem" OnClick="btnAddItem_Click" ValidationGroup="vg1">
                        <span >
                            <img src="<%=ResolveUrl("~/Images/add.png")%>" alt="单条添加" /></span><span>单条添加</span></asp:LinkButton>
                </div>
                <div class="Normal" oldclass="Normal" onmouseover="OverChangeClass(this);" onmouseout="ReturnClass(this)">
                    <asp:LinkButton runat="server" ID="btnSaveItem" OnClick="btnSaveItem_Click" Visible="false"
                        ValidationGroup="vg1">
                        <span >
                            <img src="<%=ResolveUrl("~/Images/Icon/Action/save.gif")%>" alt="保存" /></span><span>保存</span></asp:LinkButton>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="5" style="width: 100%; border-left: #99bbe8 1px solid; border-right: #99bbe8 1px solid;
                height: 5px">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="FieldName" style="border-left: #99bbe8 1px solid;">
                <span>&nbsp;值班人员：</span>
            </td>
            <td class="FieldInput" colspan="4" style="border-right: #99bbe8 1px solid;">
                <div style="display: none">
                    <asp:TextBox ID="txtUserID" runat="server" CssClass="InputSmall"></asp:TextBox>
                    <asp:TextBox ID="txtUserName" runat="server" CssClass="InputSmall"></asp:TextBox>
                    <asp:TextBox runat="server" ID="txtOtherUserID" runat="server" CssClass="InputSmall"
                        onfocus="SelectOtherUser();" Width="90%"></asp:TextBox>
                </div>
                <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td width="100">
                            平台用户：
                        </td>
                        <td>
                            <asp:TextBox ID="txtUserDisplayName" runat="server" CssClass="InputSmall" onfocus="SelectUser();"
                                Width="150"></asp:TextBox>
                        </td>
                        <td width="100">
                            其他用户
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="txtOtherUserDisplay" runat="server" CssClass="InputSmall"
                                onfocus="SelectOtherUser();" Width="150"></asp:TextBox>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td class="FieldName" width="100" style="border-left: #99bbe8 1px solid;">
                <span>&nbsp;值班日期：</span>
            </td>
            <td class="FieldInput" width="100">
                <asp:TextBox ID="tbAttendDate" Width="116px" runat="server" onfocus="calendar();"
                    CssClass="InputSmall"></asp:TextBox>
            </td>
            <td align="right" width="160">
                <span style="color: #15428b;">&nbsp;值班时间：</span>
                <asp:DropDownList runat="server" ID="ddlStartHour">
                </asp:DropDownList>
                <asp:DropDownList runat="server" ID="ddlStartMinute">
                </asp:DropDownList>
            </td>
            <td class="FieldInput" colspan="2" valign="middle" align="left" style="border-right: #99bbe8 1px solid;">
                &nbsp;至&nbsp;
                <asp:DropDownList runat="server" ID="ddlEndHour">
                </asp:DropDownList>
                <asp:DropDownList runat="server" ID="ddlEndMinute">
                </asp:DropDownList>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:CheckBox runat="server" Text="双休日" ID="cbIsWeekEnd" />
                <asp:CheckBox runat="server" Text="节假日" ID="cbIsholiday" />
            </td>
        </tr>
        <tr>
            <td class="FieldName" style="border-left: #99bbe8 1px solid;">
                <span>&nbsp;值班类型：</span>
            </td>
            <td colspan="4" class="FieldInput" style="border-right: #99bbe8 1px solid;">
                <asp:DropDownList runat="server" ID="rpType">
                   
                </asp:DropDownList>
                <asp:RequiredFieldValidator runat="server" ValidationGroup="vg1" ErrorMessage="请选择"
                    ControlToValidate="rpType"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td colspan="5" style="border-left: #99bbe8 1px solid; border-right: #99bbe8 1px solid;
                border-bottom: #99bbe8 1px solid;">
                <hr />
            </td>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="DescriptionContentPlaceHolder" runat="Server">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="MainInfolist">
        <tr class="FTitle">
            <td colspan="5" style="border: #99bbe8 1px solid;" class="TitleBar">
                <div class="MainTitle">
                    值班安排列表</div>
                <div class="Normal" oldclass="Normal" onmouseover="OverChangeClass(this);" onmouseout="ReturnClass(this)">
                    <asp:LinkButton runat="server" ID="btnDelPlan" OnClick="btnDelPlan_Click" CausesValidation="false">
                        <span >
                            <img src="<%=ResolveUrl("~/Images/Icon/Action/delete.gif")%>" alt="批量删除" /></span><span>批量删除</span></asp:LinkButton>
                </div>
            </td>
        </tr>
    </table>
    <div style="overflow: scroll; height: 165px; overflow-x: hidden;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="MainInfolist">
            <tr align="left">
                <td width="20px">
                    &nbsp;
                </td>
                <td align="center">
                    &nbsp;&nbsp;值班日期
                </td>
                <td align="center">
                    值班时间
                </td>
                <td align="center">
                    双休日
                </td>
                <td align="center">
                    节假日
                </td>
                <td align="left">
                    值班类型
                </td>
                <td align="left">
                    值班人员
                </td>
                <td width="70px">
                    &nbsp;
                </td>
            </tr>
            <asp:Repeater ID="rptItemList" runat="server" OnItemCommand="rptItemList_ItemCommand">
                <ItemTemplate>
                    <tr id="TableRow_<%# Container.ItemIndex%>" style="cursor: hand" class="Normal" oldclass="Normal"
                        onmouseover="OverChangeClass(this);" onmouseout="ReturnClass(this)">
                        <td align="center">
                            <asp:CheckBox runat="server" ID="cbItem" />
                            <asp:HiddenField runat="server" ID="hidItem" Value='<%#Eval("aIndex")%>' />
                        </td>
                        <td align="center">
                            &nbsp;&nbsp;<%# ((DateTime)DataBinder.Eval(Container.DataItem, "AttendDate")).ToString("yy-MM-dd")%>
                        </td>
                        <td align="center">
                            <span title='<%# ((DateTime)DataBinder.Eval(Container.DataItem, "AttendTimeStart")).ToString("HH:mm")%>'>
                                &nbsp;<%# ((DateTime)DataBinder.Eval(Container.DataItem, "AttendTimeStart")).ToString("HH:mm")%></span>
                            &nbsp;至<span title='<%# ((DateTime)DataBinder.Eval(Container.DataItem, "AttendTimeEnd")).ToString("HH:mm")%>'>&nbsp;<%# ((DateTime)DataBinder.Eval(Container.DataItem, "AttendTimeEnd")).ToString("HH:mm")%></span>
                        </td>
                        <td align="center">
                            <asp:CheckBox runat="server" Enabled="false" ID="cbWeekEnd" Checked='<%#Eval("IsWeekEnd")%>' />
                        </td>
                        <td align="center">
                            <asp:CheckBox runat="server" Enabled="false" ID="cbHoliday" Checked='<%#Eval("IsHoliday")%>' />
                        </td>
                        <td align="left">
                            <%#Eval("Remark2")%>
                        </td>
                        <td align="left">
                            <%#Eval("UserDisplayName")%><%#Eval("UserDisplayName").ToString() == string.Empty ? "" : ";"%><%# Eval("OtherUserName") %>
                        </td>
                        <td align="center">
                            &nbsp;<asp:LinkButton ID="lbtnDelete" runat="server" CommandName="Delete" CausesValidation="false"><span><img src="../Images/Icon/Action/delete.gif" alt="删除" /></span></asp:LinkButton>
                            &nbsp;<asp:LinkButton ID="lbtnEdit" runat="server" CommandName="Edit" CausesValidation="false"><span><img src="../Images/Icon/Action/edit.gif" alt="编辑" /></span></asp:LinkButton>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>
    </div>
</asp:Content>
